(*

let glpath = "/usr/lib/libGL.so"

let glpath = ""

let () = Hal.init (glpath)



let () = 
    Hal.make_window 320 200 32

let () = Hal.Window.set_caption "Hello" "world"

let () = Printf.printf "bla\n"
let () = flush stdout

let a,b = Hal.Window.get_caption ()

let () = Printf.printf "bla\n"
let () = flush stdout


let () = Printf.printf "%s %s\n" a b
let () = flush stdout


let () = Hal.delay 2000

let () =
    Hal.Window.iconify_window ()
    
    
let rec loop () = 
    let e = Hal.Event.wait_event () in
    Printf.printf "%s\n" (Hal.Event.string_of_event e);
    flush stdout;
    Hal.delay 300;    
    Hal.Event.push_event { Hal.Event.code = 0; Hal.Event.data1 = "hallo"; Hal.Event.data2 = "world" };
    loop ()

let () = loop ()

*)

let read_file f =
	let ic = open_in_bin f in
	let len = in_channel_length ic in
	let s = String.create len in
	let _ = really_input ic s 0 len in
	s

let () = Hal.init ("")

let () = 
    Hal.Window.make_window 320 200 32

let () = Hal.Audio.init_sound (int_of_string Sys.argv.(2)) (int_of_string Sys.argv.(3))
	
let s = Hal.Audio.load_wav (read_file Sys.argv.(1))

let () = Hal.Audio.assign_sound_to_sample s 0

let () = Hal.Audio.assign_sample_to_voice Hal.Audio.samples.(0) 0

let () = Hal.Audio.assign_sample_to_voice Hal.Audio.samples.(0) 1 

let () = Hal.Audio.loop_sound 0 true

let () = Hal.Audio.mute false

let () = Hal.Audio.play_sound 0 true

let () = Hal.Time.delay 5000 

let () = Hal.Audio.play_sound 1 true

let () = Hal.Time.delay 5000



   
